﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using lakethaiClassLibrary;
using System.IO;

public partial class home_contact : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = Resources.header.contactTitle;
        try
        {
            this.lblMessage.Text = HttpContext.Current.Session["myMessage"].ToString();
        }
        catch {}
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string hoten = txtHoten.Text;
        string email = txtEmail.Text;
        string diachi = txtDiachi.Text;
        string tieude = txtTieude.Text;
        string noidung = txtNoidung.Text;
        string theMessage = System.IO.File.ReadAllText(app_helper.ContactMailLocation);
        theMessage = theMessage.Replace("[tieude]", tieude);
        theMessage = theMessage.Replace("[nguoigui]", hoten);
        theMessage = theMessage.Replace("[email]", email);
        theMessage = theMessage.Replace("[diachi]", diachi);
        theMessage = theMessage.Replace("[noidung]", noidung);
        bool b;
        b = myHelp.SendGmail("smtp.gmail.com",
            465,
            "autosender155",
            "hothai@123",
            hoten,
            email,
            "Admin",
            "hothai.vvn@gmail.com", //thay địa chỉ email nhận tt liên hệ ở đây
            "Liên hệ từ haanhcompany.vn",
            theMessage,
            true);
        b = myHelp.SendGmail("smtp.gmail.com",
            465,
            "autosender155",
            "hothai@123",
            hoten,
            email,
            "Admin",
            "hagiang@gmail.com",
            "Liên hệ từ haanhcompany.vn",
            theMessage,
            true);
        if (b)
        {
            if (HttpContext.Current.Session["lancode"].ToString().CompareTo("en") == 0)
                HttpContext.Current.Session["myMessage"] = "Thankyou so much for your contact! We 'll reply for you as soon as we 're able to do.";
            else
                HttpContext.Current.Session["myMessage"] = "Cảm ơn bạn vì đã liên hệ với chúng tôi! Chúng tôi sẽ phản hồi lại cho bạn ngay khi có thể!";
            Response.Redirect("contact.aspx");
        }
    }
}
